#pragma once

#include <map>
#include "EnginePointer.h"
#include "EngineObject.h"
#include "BaseDator.h"
#include "Dator.h"
#include "ListDator.h"
#include "ISerializer.h"

typedef struct SettingsManagerStringCmp: binary_function<char const *, char const*, bool>
{
	bool operator()(char const* g1, char const* g2) const
	{
		return strcmp(g1, g2) < 0;
	}
} SettingsManagerStringCmp;

class SettingsManager : public EngineObject
{
public:
	SettingsManager(EnginePointer<ISerializer> serializer);
	virtual ~SettingsManager();
	
	char* GetVariableAsString(char* name);
	bool GetVariableAsBool(char* name);
	signed char GetVariableAsSChar(char* name);
	unsigned char GetVariableAsUChar(char* name);
	signed short int GetVariableAsSShort(char* name);
	unsigned short int GetVariableAsUShort(char* name);
	signed long int GetVariableAsSLong(char* name);
	unsigned long int GetVariableAsULong(char* name);
	float GetVariableAsFloat(char* name);
	double GetVariableAsDouble(char* name);
	long double GetVariableAsLongDouble(char* name);
	signed long long GetVariableAsSLongLong(char* name);
	unsigned long long GetVariableAsULongLong(char* name);

	void SetVariable(char* name, char* value);
	void SetVariable(char* name, bool value);
	void SetVariable(char* name, signed char value);
	void SetVariable(char* name, unsigned char value);
	void SetVariable(char* name, signed short int value);
	void SetVariable(char* name, unsigned short int value);
	void SetVariable(char* name, signed long int value);
	void SetVariable(char* name, unsigned long int value);
	void SetVariable(char* name, float value);
	void SetVariable(char* name, double value);
	void SetVariable(char* name, long double value);
	void SetVariable(char* name, signed long long int value);
	void SetVariable(char* name, unsigned long long int value);

	void ReadSettings();
	void WriteSettings();

	AUTO_SIZE;
protected:
	EnginePointer<ISerializer> serializer;
	map<char*, char*, SettingsManagerStringCmp> settingMap;
};
